package com.fzq.util;

import lombok.Data;

@Data
public class ResponseResult<T> {
    private int status;
    private String msg;
    private T data;

    public ResponseResult() {
    }

    public ResponseResult(int status, String msg) {
        this.status = status;
        this.msg = msg;
    }

    public ResponseResult(int status, String msg, T data) {
        this(status, msg);
        this.data = data;
    }

    public ResponseResult(int status, T data) {
        this.status=status;
        this.data = data;
    }

    public static ResponseResult<Void> SUCCESS = new ResponseResult<>(200, "成功");
    public static ResponseResult<Void> INTENER_ERROR = new ResponseResult<>(500, "服务器错误");
    public static ResponseResult<Void> NOT_FOUND = new ResponseResult<>(404, "未找到");
	
	public static ResponseResult<Void> success(String msg){
        return new ResponseResult<>(200,msg);
    }

    public static <T> ResponseResult<T> success(String msg,T data){
        return new ResponseResult<T>(200, msg,data);
    }

    public static ResponseResult<Void> error(String msg){
        return new ResponseResult<>(500,msg);
    }

    public static ResponseResult<Void> error(ResultCode resultCode){
        return new ResponseResult<>(resultCode.getCode(),resultCode.getMessage());
    }


}
